<template>
	<view>
		<view class="head_con">
			<view class="u-text-center u-border-bottom" style="padding:20rpx 0;">
				<view style="font-size: 35rpx;">总资产数</view>
				<view style="font-size: 50rpx;padding:30rpx 0;">{{allnum.total}}</view>
			</view>
			<view class="u-flex u-row-between">
				<view class="head_list">
					<text>待入库</text>
					<text class="dis_blo">{{allnum.numIn}}</text>
				</view>
				<view class="head_list">
					<text>待出库</text>
					<text class="dis_blo">{{allnum.numOut}}</text>
				</view>
				<view class="head_list">
					<text>已入库</text>
					<text class="dis_blo">{{allnum.numInEd}}</text>
				</view>
				<view class="head_list">
					<text>已出库</text>
					<text class="dis_blo">{{allnum.numOutEd}}</text>
				</view>
			</view>
		</view>
		<view class="u-padding-20 u-flex u-row-between">
			<view class="mian_menu mian_menu0" @click="toputout">
				<!-- <text>出库</text> -->
			</view>
			<view class="mian_menu mian_menu1" @click="toputin">
				<!-- <text>入库</text> -->
			</view>
			<view class="mian_menu mian_menu2" @click="tosecondIndex">
				<!-- <text>盘点</text> -->
			</view>
		</view>
		<view>
			<view style="background-color: #f5f5f5 !important;">
				<u-tabs :list="tabs" :bold='true' bg-color="#f5f5f5" activeColor="#0B868E" :current="current" @change="changeTabs">
				</u-tabs>
			</view>
			<view class="list_content">
				<u-empty :show="showEmpty" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
				</u-empty>
				<view class="con_list u-border-bottom u-rela" v-for="(item,index) in list" :key="index">
					<block v-if="item.type==0">
						<view v-if="item.status==0" style="color:#f00;font-size: 26rpx;" class="u-abso pos_right">待审核</view>
						<view v-else-if="item.status==1" style="color:#00aa00;font-size: 26rpx;" class="u-abso pos_right">审核通过</view>
						<view v-else style="color:#ff5500;font-size: 26rpx;" class="u-abso pos_right">审核拒接</view>
					</block>
					<block v-else>
						<block v-if="item.is_examine==0">
							<view style="color:#f00;font-size: 26rpx;" class="u-abso pos_right">待审批</view>
						</block>
						<block v-else-if="item.is_examine==1">
							<view v-if="item.status==0" style="color:#f00;font-size: 26rpx;" class="u-abso pos_right">待审核</view>
							<view v-else-if="item.status==1" style="color:#00aa00;font-size: 26rpx;" class="u-abso pos_right">审核通过</view>
							<view v-else style="color:#ff5500;font-size: 26rpx;" class="u-abso pos_right">审核拒接</view>
						</block>
						<block v-else>
							<view style="color:#ff5500;font-size: 26rpx;" class="u-abso pos_right">审批未通过</view>
						</block>
					</block>
					
					
					<image :src="item.image" mode="aspectFill"></image>
					<view class="dis_inl_blo con_intro">
						<view class="title_name">{{item.name}}</view>
						<view class="person_con">
							<text>数量：{{item.num}}</text>
							<text class="u-margin-left-20">总价：<text style="color:red;font-size:32rpx;">￥{{item.price}}</text></text>
							<!-- <text class="dis_blo"></text> -->
						</view>
						<view class="person_con" style="font-size: 26rpx;color:#008987;">#{{item.nav}}#</view>
						<block v-if="item.type==0">
							<view class="price u-abso u-text-right" style="bottom:20rpx;">
								<text class="detail" @click="toDetail(item)">查看详情</text>
								<text v-if="item.status==0" class="rubtn u-margin-left-30" @click="toshowmodal(item.id)">审核通过</text>
							</view>
						</block>
						<block v-else>
							<view class="price u-abso u-text-right" style="bottom:20rpx;" v-if="item.is_examine==0">
								<text class="detail" @click="toDetail(item)">查看详情</text>
								<text v-if="type==1 || type==2" class="rubtn u-margin-left-30" @click="approve(item.id)">审批通过</text>
							</view>
							<view class="price u-abso u-text-right" style="bottom:20rpx;" v-else-if="item.is_examine==1 && item.status==0">
								<text class="detail" @click="toDetail(item)">查看详情</text>
								<text class="rubtn u-margin-left-30" @click="toshowmodal(item.id)">审核通过</text>
							</view>
							<view class="price u-abso u-text-right" style="bottom:20rpx;" v-else>
								<text class="detail" @click="toDetail(item)">查看详情</text>
							</view>
						</block>
					</view>
				</view>
			</view>
		</view>
		<!-- 弹框提示 -->
		<u-toast ref="uToast" />
		<!-- 审核 -->
		<u-modal v-model="showmodal" :mask-close-able="true" confirm-color="#008987" :show-cancel-button="true"
		 :content="content" @confirm="confirm"></u-modal>
		 <!-- 审批 -->
		 <u-modal v-model="showapprove" :mask-close-able="true" confirm-color="#008987" :show-cancel-button="true"
		  :content="approvecontent" @confirm="confirmapprove"></u-modal>
	</view>
</template>

<script>
	import cookie from "@/util/store/cookie";
	import {
		getAssetsLogList,assetsExamine,getAssetsStatic,approve
	} from "@/service/assetService.js";
	export default {
		data () {
			return {
				// topics: [],
				current: 0,
				type:0,
				tabs: [
					{
						name: '全部'
					},
					{
						name: '采购'
					},
					{
						name: '领取'
					},
					{
						name: '借还'
					},
					// {
					// 	name: '归还'
					// }
				],
				showEmpty:false,
				list:[],
				allnum:{},
				id:0,
				showmodal:false,
				content:'您确认给予该条信息审核通过？',
				showapprove:false,
				approvecontent:'您确认给予该条信息审批通过？'
			}
			
		},
		onLoad() {
			getAssetsLogList({type:99}).then(this.getAssetsLogList);
			getAssetsStatic().then(this.getAssetsStatic);
			this.type=cookie.get('type')
		},
		onReachBottom() {
			
		},
		methods:{
			getAssetsLogList(e){
				if(e.code==200){
					this.list=e.result;
					this.showEmpty=false
				}else{
					this.list=[];
					this.showEmpty=true
				}
			},
			getAssetsStatic(e){
				if(e.code==200){
					this.allnum=e.result
				}
			},
			toputin:function(){
				uni.navigateTo({
					url:'./putInStorage'
				})
			},
			toputout:function(){
				uni.navigateTo({
					url:'./putOutStorage'
				})
			},
			toshowmodal(id){
				this.id=id;
				this.showmodal=true;
			},
			approve(id){
				this.id=id;
				this.showapprove=true
			},
			toDetail(item){
				if(item.type==0){
					uni.navigateTo({
						url:'./inDetail?item='+encodeURIComponent(JSON.stringify(item))
						// url:'./inDetail?id='+id
					})
				}else{
					uni.navigateTo({
						url:'./outDetail?item='+encodeURIComponent(JSON.stringify(item))
						// url:'./inDetail?id='+id
					})
				}
			},
			changeTabs(e) {
				let par;
				this.current = e;
				switch (this.current) {
					case 0:
						par = {
							type:99
						};
						break;
					case 1:
						par = {
							type:0
						};
						break;
					case 2:
						par = {
							type:1
						};
						break;
					case 3:
						par = {
							type:2
						};
						break;
					
					default:
						par = {
							type:99
						};
				}
				getAssetsLogList(par).then(this.getAssetsLogList);
			},
			toprocurement(){
				uni.navigateTo({
					url:'./procurement'
				})
			},
			tosecondIndex(){
				uni.navigateTo({
					url:'./secondIndex'
				})
			},
			confirm(){
				assetsExamine({
					id:this.id,
					status:1
				}).then(res=>{
					if(res.code==200){
						this.$refs.uToast.show({
							type: 'success',
							title: '审核成功',
							icon:false
						})
						this.current=0;
						getAssetsLogList({type:99}).then(this.getAssetsLogList)
					}else{
						this.$refs.uToast.show({
							type: 'error',
							title: res.msg,
							icon:false
						})
					}
				})
			},
			confirmapprove(){
				approve({
					id:this.id,
					is_examine:1
				}).then(res=>{
					if(res.code==200){
						this.$refs.uToast.show({
							type: 'success',
							title: '审批成功',
							icon:false
						})
						this.current=0;
						getAssetsLogList({type:99}).then(this.getAssetsLogList)
					}else{
						this.$refs.uToast.show({
							type: 'error',
							title: res.msg,
							icon:false
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f5f5f5;
	}
	.head_con{
		width:100%;
		height:350rpx;
		color:#fff;
		// background-color: #550000;
		background-image: url(https://resourse.cnlhjt.com/upload/20220824/d6238e536fde4e7fe1a23369cc031aa9.png);
		background-size: cover;
		background-position: center;
	}
	.head_list{
		text-align: center;
		padding:30rpx 0;
		width:25%;
		border-right:1rpx solid #fff;
	}
	.mian_menu{
		width:30%;
		padding:20rpx;
		height:150rpx;
		color:#fff;
		font-weight: bold;
		// background-image: url(https://s1.ax1x.com/2022/07/18/jIO4Ln.png);
		background-size: cover;
		background-position: center;
	}
	.mian_menu0{
		background-image: url(https://resourse.cnlhjt.com/upload/20220824/d3ef2d9833941c0d5bf7c914dd803f22.png);
	}
	.mian_menu1{
		background-image: url(https://resourse.cnlhjt.com/upload/20220824/acbb8433a653fec978be83b4d1deaa2d.png);
	}
	.mian_menu2{
		background-image: url(https://resourse.cnlhjt.com/upload/20220824/9726611d51d4d40942d3d6920a2df0d8.png);
	}
	.list_content{
		width:95%;
		margin:20rpx auto;
		// padding:20rpx;
		background-color: #fff;
		border-radius: 20rpx;
	}
	.con_list{
		padding:20rpx;
	}
	.con_list image{
		width:25%;
		height:180rpx;
		border-radius: 10rpx;
		vertical-align: top;
	}
	.con_intro{
		width:70%;
		margin-left:15rpx;
		vertical-align: top;
	}
	.person_con{
		margin-top:10rpx;
		font-size: 26rpx;
		color:#666;
	}
	.title_name{
		width:80%;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.price{
		width:70%;
		bottom:50rpx;
		font-size: 28rpx;
	}
	.detail{
		right:190rpx;
		font-size: 26rpx;
		color:#0f848c;
		padding:3rpx 25rpx;
		border:1rpx solid #0f848c;
		border-radius: 18rpx;
	}
	.rubtn{
		
		font-size: 26rpx;
		color:#fff;
		padding:3rpx 28rpx;
		// border:1rpx solid #0f848c;
		border-radius: 18rpx;
		background-image: linear-gradient(to right,#53a7ad,#0f848c);
	}
</style>



